#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;

class Solution {
public:
    vector<string> permutation(string s) {
        if(s.size()==1){
            vector<string> T ;
            T.push_back(s);
            return T;
        }
        vector<string> result;
        set<char> S;
        for(int i = 0;i<s.size();++i){
            if(S.insert(s[i]).second!=false){
            string temp = s;
            temp.erase(i,1);
            vector<string> tempStr = permutation(temp);
            for(int j = 0;j<tempStr.size();++j){
                string F = s[i]+tempStr[j];
                result.push_back(F);
            }
            }
        }
        return result;
    }
};

int main(){
    Solution S;
    vector<string> T = S.permutation("abc");
    return 0;
}